package com.atguigu.principle.singleresponsibility.inversion.improve;

/**
 * @Author: yangtao
 * @Description: 倒转模式
 */
public class Dependecyinversion {

    public static void main(String[] args) {
        //客户端调用
        Person person = new Person();
        person.receive(new Email());

        person.receive(new WeiXin());
    }
}

//定义接口
interface  IReceiver{
    public  String getInfo();

}
//邮件类
class Email implements IReceiver {
    public String getInfo() {

        return "电子邮件信息: helloworld";
    }
}

//微信
class WeiXin implements IReceiver{
    public String getInfo(){
        return "微信信息: hello,ok";
    }

}
//方式定义
class Person {

    public void receive(IReceiver receiver) {
        System.out.println(receiver.getInfo());
    }

}
